<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>~/GRAPE/sim.cpp.html</title>
<meta name="Generator" content="Vim/7.4">
<meta name="plugin-version" content="vim7.4_v2">
<meta name="syntax" content="cpp">
<meta name="settings" content="number_lines,use_css,pre_wrap,no_foldcolumn,expand_tabs,line_ids,prevent_copy=">
<meta name="colorscheme" content="none">
<style type="text/css">
<!--
pre { white-space: pre-wrap; font-family: monospace; color: #ffffff; background-color: #000000; }
body { font-family: monospace; color: #ffffff; background-color: #000000; }
* { font-size: 1em; }
.Comment { color: #00ffff; }
.Constant { color: #ff40ff; }
.LineNr { color: #ffff00; }
.Statement { color: #ffff00; }
.PreProc { color: #5fd7ff; }
.Type { color: #87ffaf; }
-->
</style>

<script type='text/javascript'>
<!--

/* function to open any folds containing a jumped-to line before jumping to it */
function JumpToLine()
{
  var lineNum;
  lineNum = window.location.hash;
  lineNum = lineNum.substr(1); /* strip off '#' */

  if (lineNum.indexOf('L') == -1) {
    lineNum = 'L'+lineNum;
  }
  lineElem = document.getElementById(lineNum);
  /* Always jump to new location even if the line was hidden inside a fold, or
   * we corrected the raw number to a line ID.
   */
  if (lineElem) {
    lineElem.scrollIntoView(true);
  }
  return true;
}
if ('onhashchange' in window) {
  window.onhashchange = JumpToLine;
}

-->
</script>
</head>
<body onload='JumpToLine();'>
<pre id='vimCodeElement'>
<span id="L1" class="LineNr">  1 </span><span class="PreProc">#include </span><span class="Constant">&lt;vector&gt;</span>
<span id="L2" class="LineNr">  2 </span><span class="PreProc">#include </span><span class="Constant">&lt;stack&gt;</span>
<span id="L3" class="LineNr">  3 </span><span class="PreProc">#include </span><span class="Constant">&lt;queue&gt;</span>
<span id="L4" class="LineNr">  4 </span><span class="PreProc">#include </span><span class="Constant">&lt;unordered_map&gt;</span>
<span id="L5" class="LineNr">  5 </span><span class="PreProc">#include </span><span class="Constant">&lt;unordered_set&gt;</span>
<span id="L6" class="LineNr">  6 </span><span class="PreProc">#include </span><span class="Constant">&lt;algorithm&gt;</span>
<span id="L7" class="LineNr">  7 </span><span class="PreProc">#include </span><span class="Constant">&lt;gflags/gflags.h&gt;</span>
<span id="L8" class="LineNr">  8 </span>
<span id="L9" class="LineNr">  9 </span><span class="PreProc">#include </span><span class="Constant">&quot;core/grape.h&quot;</span>
<span id="L10" class="LineNr"> 10 </span><span class="PreProc">#include </span><span class="Constant">&quot;utils/util.h&quot;</span>
<span id="L11" class="LineNr"> 11 </span><span class="PreProc">#include </span><span class="Constant">&quot;SimTemporal.hpp&quot;</span>
<span id="L12" class="LineNr"> 12 </span>
<span id="L13" class="LineNr"> 13 </span><span class="Statement">using</span> <span class="Type">namespace</span> std;
<span id="L14" class="LineNr"> 14 </span>
<span id="L15" class="LineNr"> 15 </span><span class="Type">template</span>&lt;<span class="Type">class</span> VD, <span class="Type">class</span> ED, <span class="Type">class</span> MessageT, <span class="Type">class</span> ResultT, <span class="Type">class</span> TemporalT&gt;
<span id="L16" class="LineNr"> 16 </span><span class="Type">class</span> SimWorker: <span class="Statement">public</span> Worker&lt;VD, ED, MessageT, ResultT, TemporalT&gt; {
<span id="L17" class="LineNr"> 17 </span>    <span class="Type">void</span> pEval(Fragment&lt;VD, ED&gt; &amp;fragment, MessageBuffer&lt;MessageT&gt; &amp;messageBuffer, ResultT &amp;partialResult, TemporalT &amp;temporal) {
<span id="L18" class="LineNr"> 18 </span>        unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt; simSet, rmSet;
<span id="L19" class="LineNr"> 19 </span>
<span id="L20" class="LineNr"> 20 </span>        unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt; tSet;
<span id="L21" class="LineNr"> 21 </span>        unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt; prePattern;
<span id="L22" class="LineNr"> 22 </span>
<span id="L23" class="LineNr"> 23 </span>        unordered_map&lt;<span class="Type">int</span>, VertexID&gt; tag2ID;
<span id="L24" class="LineNr"> 24 </span>        unordered_map&lt;VertexID, vector&lt;<span class="Type">unsigned</span>&gt;&gt; cnt;
<span id="L25" class="LineNr"> 25 </span>        unordered_map&lt;VertexID, <span class="Type">bool</span>&gt; active;
<span id="L26" class="LineNr"> 26 </span>
<span id="L27" class="LineNr"> 27 </span>        unordered_set&lt;VertexID&gt; preV;
<span id="L28" class="LineNr"> 28 </span>
<span id="L29" class="LineNr"> 29 </span>        <span class="Type">auto</span> allVertices = *fragment.getInnerVertices();
<span id="L30" class="LineNr"> 30 </span>
<span id="L31" class="LineNr"> 31 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> v : *fragment.getOuterVertices()) {
<span id="L32" class="LineNr"> 32 </span>            allVertices.insert(v);
<span id="L33" class="LineNr"> 33 </span>        }
<span id="L34" class="LineNr"> 34 </span>
<span id="L35" class="LineNr"> 35 </span><span class="Comment">//      this-&gt;pattern.buildSignature(this-&gt;pattern.getAllVerticesID(), true, false);</span>
<span id="L36" class="LineNr"> 36 </span>        <span class="Statement">this</span>-&gt;query.buildSignature();
<span id="L37" class="LineNr"> 37 </span>
<span id="L38" class="LineNr"> 38 </span>
<span id="L39" class="LineNr"> 39 </span>
<span id="L40" class="LineNr"> 40 </span>        <span class="Statement">for</span> (VertexID u = <span class="Constant">0</span>; u &lt; <span class="Statement">this</span>-&gt;query.getNumVertices(); ++u) {
<span id="L41" class="LineNr"> 41 </span>            <span class="Type">int</span> tag = <span class="Statement">this</span>-&gt;query.getVertexAttr(u);
<span id="L42" class="LineNr"> 42 </span>            tag2ID[tag] = u;
<span id="L43" class="LineNr"> 43 </span>
<span id="L44" class="LineNr"> 44 </span>            <span class="Type">auto</span> pSet = <span class="Statement">this</span>-&gt;query.getParentsID(u);
<span id="L45" class="LineNr"> 45 </span>            prePattern[u] = unordered_set&lt;VertexID&gt;(pSet.begin(), pSet.end());
<span id="L46" class="LineNr"> 46 </span>            simSet[u] = unordered_set&lt;VertexID&gt;();
<span id="L47" class="LineNr"> 47 </span>            rmSet[u] = unordered_set&lt;VertexID&gt;();
<span id="L48" class="LineNr"> 48 </span>        }
<span id="L49" class="LineNr"> 49 </span>
<span id="L50" class="LineNr"> 50 </span>
<span id="L51" class="LineNr"> 51 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> v : allVertices) {
<span id="L52" class="LineNr"> 52 </span>            <span class="Type">int</span> tag = fragment.getVertexAttr(v);
<span id="L53" class="LineNr"> 53 </span>            <span class="Statement">if</span> (tag2ID.find(tag) != tag2ID.end()) {
<span id="L54" class="LineNr"> 54 </span><span class="Comment">//              if (fragment.isOuterVertex(v) || match(this-&gt;pattern.getSig(OUT_R1, tag2ID[tag]), fragment.getSig(OUT_R1, v))) {</span>
<span id="L55" class="LineNr"> 55 </span><span class="Comment">//              if (!fragment.isInnerVertex(v) || match(this-&gt;query.getSignature(OUT_R1, tag2ID[tag]), fragment.getSignature(OUT_R1, v))) {</span>
<span id="L56" class="LineNr"> 56 </span>                cnt[v] = vector&lt;<span class="Type">unsigned</span>&gt;(<span class="Statement">this</span>-&gt;query.getNumVertices(), <span class="Constant">0</span>);
<span id="L57" class="LineNr"> 57 </span>                active[v] = <span class="Constant">true</span>;
<span id="L58" class="LineNr"> 58 </span>                <span class="Statement">if</span> (fragment.hasChild(v)) {
<span id="L59" class="LineNr"> 59 </span>                    preV.insert(v);
<span id="L60" class="LineNr"> 60 </span>                }
<span id="L61" class="LineNr"> 61 </span>            }
<span id="L62" class="LineNr"> 62 </span>        }
<span id="L63" class="LineNr"> 63 </span>
<span id="L64" class="LineNr"> 64 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> vtx : active) {
<span id="L65" class="LineNr"> 65 </span>            <span class="Comment">// vtx is a element of the active map.</span>
<span id="L66" class="LineNr"> 66 </span>            <span class="Comment">// vtx.first should be one of the active vertexID.</span>
<span id="L67" class="LineNr"> 67 </span>            VertexID v = vtx.first;
<span id="L68" class="LineNr"> 68 </span>            <span class="Type">int</span> tag = fragment.getVertexAttr(v);
<span id="L69" class="LineNr"> 69 </span>            VertexID u = tag2ID[tag];
<span id="L70" class="LineNr"> 70 </span>            <span class="Statement">if</span> (!<span class="Statement">this</span>-&gt;query.hasChild(u) || fragment.hasChild(v)  || !fragment.isInnerVertex(v)) {
<span id="L71" class="LineNr"> 71 </span>                <span class="Statement">for</span> (<span class="Type">auto</span> p : fragment.getParentsID(v)) {
<span id="L72" class="LineNr"> 72 </span>                    <span class="Statement">if</span> (active.find(p) != active.end()) {
<span id="L73" class="LineNr"> 73 </span>                        ++cnt[p][tag];
<span id="L74" class="LineNr"> 74 </span>                        rmSet[u].insert(p);
<span id="L75" class="LineNr"> 75 </span>                    }
<span id="L76" class="LineNr"> 76 </span>                }
<span id="L77" class="LineNr"> 77 </span>            } <span class="Statement">else</span> {
<span id="L78" class="LineNr"> 78 </span>                active[v] = <span class="Constant">false</span>;
<span id="L79" class="LineNr"> 79 </span>            }
<span id="L80" class="LineNr"> 80 </span>        }
<span id="L81" class="LineNr"> 81 </span>
<span id="L82" class="LineNr"> 82 </span>        <span class="Statement">for</span> (VertexID u = <span class="Constant">0</span>; u &lt; <span class="Statement">this</span>-&gt;query.getNumVertices(); ++u) {
<span id="L83" class="LineNr"> 83 </span>            rmSet[u] = diff(preV, rmSet[u]);
<span id="L84" class="LineNr"> 84 </span>        }
<span id="L85" class="LineNr"> 85 </span>
<span id="L86" class="LineNr"> 86 </span>        queue&lt;VertexID&gt; que;
<span id="L87" class="LineNr"> 87 </span>        vector&lt;<span class="Type">bool</span>&gt; inQue(<span class="Statement">this</span>-&gt;query.getNumVertices(), <span class="Constant">false</span>);
<span id="L88" class="LineNr"> 88 </span>        <span class="Statement">for</span> (VertexID u = <span class="Constant">0</span>; u &lt; <span class="Statement">this</span>-&gt;query.getNumVertices(); ++u) {
<span id="L89" class="LineNr"> 89 </span>            <span class="Statement">if</span> (!rmSet[u].empty()) {
<span id="L90" class="LineNr"> 90 </span>                que.push(u);
<span id="L91" class="LineNr"> 91 </span>                inQue[u] = <span class="Constant">true</span>;
<span id="L92" class="LineNr"> 92 </span>            }
<span id="L93" class="LineNr"> 93 </span>        }
<span id="L94" class="LineNr"> 94 </span>
<span id="L95" class="LineNr"> 95 </span>        <span class="Statement">for</span> (; !que.empty(); que.pop()) {
<span id="L96" class="LineNr"> 96 </span>            VertexID u = que.front();
<span id="L97" class="LineNr"> 97 </span>            inQue[u] = <span class="Constant">false</span>;
<span id="L98" class="LineNr"> 98 </span>            <span class="Statement">for</span> (<span class="Type">auto</span> w : rmSet[u]) {
<span id="L99" class="LineNr"> 99 </span>                <span class="Type">int</span> tag = fragment.getVertexAttr(w);
<span id="L100" class="LineNr">100 </span>                <span class="Statement">if</span> (tag2ID.find(tag) != tag2ID.end()) {
<span id="L101" class="LineNr">101 </span>                    VertexID u1 = tag2ID[tag];
<span id="L102" class="LineNr">102 </span>                    <span class="Statement">if</span> (prePattern[u].find(u1) != prePattern[u].end() &amp;&amp; active[w]) {
<span id="L103" class="LineNr">103 </span>                        active[w] = <span class="Constant">false</span>;
<span id="L104" class="LineNr">104 </span>                        <span class="Statement">for</span> (<span class="Type">auto</span> w1 : fragment.getParentsID(w)) {
<span id="L105" class="LineNr">105 </span>                            <span class="Statement">if</span> (active[w1]) {
<span id="L106" class="LineNr">106 </span>                                --cnt[w1][tag];
<span id="L107" class="LineNr">107 </span>                                <span class="Statement">if</span> (cnt[w1][tag] == <span class="Constant">0</span>) {
<span id="L108" class="LineNr">108 </span>                                    rmSet[u1].insert(w1);
<span id="L109" class="LineNr">109 </span>                                    <span class="Statement">if</span> (!inQue[u1]) {
<span id="L110" class="LineNr">110 </span>                                        que.push(u1);
<span id="L111" class="LineNr">111 </span>                                        inQue[u1] = <span class="Constant">true</span>;
<span id="L112" class="LineNr">112 </span>                                    }
<span id="L113" class="LineNr">113 </span>                                }
<span id="L114" class="LineNr">114 </span>                            }
<span id="L115" class="LineNr">115 </span>                        }
<span id="L116" class="LineNr">116 </span>                    }
<span id="L117" class="LineNr">117 </span>                }
<span id="L118" class="LineNr">118 </span>            }
<span id="L119" class="LineNr">119 </span>            rmSet[u].clear();
<span id="L120" class="LineNr">120 </span>        }
<span id="L121" class="LineNr">121 </span>
<span id="L122" class="LineNr">122 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> vtx : active) {
<span id="L123" class="LineNr">123 </span>            <span class="Statement">if</span> (vtx.second) {
<span id="L124" class="LineNr">124 </span>                VertexID v = vtx.first;
<span id="L125" class="LineNr">125 </span>                <span class="Type">int</span> tag = fragment.getVertexAttr(v);
<span id="L126" class="LineNr">126 </span>                VertexID u = tag2ID[tag];
<span id="L127" class="LineNr">127 </span>                simSet[u].insert(v);
<span id="L128" class="LineNr">128 </span>            }
<span id="L129" class="LineNr">129 </span>        }
<span id="L130" class="LineNr">130 </span>
<span id="L131" class="LineNr">131 </span>        partialResult = simSet;
<span id="L132" class="LineNr">132 </span>        temporal = SimTemporal(tSet, prePattern, tag2ID, cnt, active);
<span id="L133" class="LineNr">133 </span>
<span id="L134" class="LineNr">134 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> v : *fragment.getInnerVertices()) {
<span id="L135" class="LineNr">135 </span>            <span class="Statement">if</span> (!fragment.isBorderVertexWithIncomingEdge(v)) {
<span id="L136" class="LineNr">136 </span>                <span class="Statement">continue</span>;
<span id="L137" class="LineNr">137 </span>            }
<span id="L138" class="LineNr">138 </span>            <span class="Type">int</span> tag = fragment.getVertexAttr(v);
<span id="L139" class="LineNr">139 </span>            <span class="Statement">if</span> (!active[v] &amp;&amp; tag2ID.find(tag) != tag2ID.end()) {
<span id="L140" class="LineNr">140 </span>                <span class="Type">auto</span> dest = fragment.getMsgThroughIncomingDest(v);
<span id="L141" class="LineNr">141 </span>                <span class="Statement">for</span> (<span class="Type">int</span> fid = <span class="Constant">0</span>; fid &lt; dest.size(); ++fid) {
<span id="L142" class="LineNr">142 </span>                    <span class="Statement">if</span> (dest.test(fid)) {
<span id="L143" class="LineNr">143 </span>                        messageBuffer.add_message(fid, v);
<span id="L144" class="LineNr">144 </span>                    }
<span id="L145" class="LineNr">145 </span>                }
<span id="L146" class="LineNr">146 </span>            }
<span id="L147" class="LineNr">147 </span>        }
<span id="L148" class="LineNr">148 </span>    }
<span id="L149" class="LineNr">149 </span>
<span id="L150" class="LineNr">150 </span>    <span class="Type">void</span> incEval(Fragment&lt;VD, ED&gt; &amp;fragment, MessageBuffer&lt;MessageT&gt; &amp;messageBuffer, ResultT &amp;partialResult, TemporalT &amp;temporal) {
<span id="L151" class="LineNr">151 </span>        <span class="Type">auto</span> xIn = messageBuffer.get_messages();
<span id="L152" class="LineNr">152 </span>        <span class="Comment">// auto Set = temporal.preSet;</span>
<span id="L153" class="LineNr">153 </span>        <span class="Type">auto</span> prePattern = temporal.prePattern;
<span id="L154" class="LineNr">154 </span>        <span class="Type">auto</span> tag2ID = temporal.tag2ID;
<span id="L155" class="LineNr">155 </span>        <span class="Type">auto</span> cnt = temporal.cnt;
<span id="L156" class="LineNr">156 </span>        <span class="Type">auto</span> active = temporal.active;
<span id="L157" class="LineNr">157 </span>
<span id="L158" class="LineNr">158 </span>        queue&lt;VertexID&gt; simQue;
<span id="L159" class="LineNr">159 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> v : xIn) {
<span id="L160" class="LineNr">160 </span>            <span class="Statement">if</span> (active[v]) {
<span id="L161" class="LineNr">161 </span>                simQue.push(v);
<span id="L162" class="LineNr">162 </span>                active[v] = <span class="Constant">false</span>;
<span id="L163" class="LineNr">163 </span>            }
<span id="L164" class="LineNr">164 </span>        }
<span id="L165" class="LineNr">165 </span>        unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt; deltaSet;
<span id="L166" class="LineNr">166 </span>        <span class="Statement">for</span> (<span class="Type">int</span> u = <span class="Constant">0</span>; u &lt; <span class="Statement">this</span>-&gt;query.getNumVertices(); ++u) {
<span id="L167" class="LineNr">167 </span>            deltaSet[u] = unordered_set&lt;VertexID&gt;();
<span id="L168" class="LineNr">168 </span>        }
<span id="L169" class="LineNr">169 </span>
<span id="L170" class="LineNr">170 </span>        <span class="Statement">for</span> (; !simQue.empty(); simQue.pop()) {
<span id="L171" class="LineNr">171 </span>            <span class="Type">auto</span> v = simQue.front();
<span id="L172" class="LineNr">172 </span>
<span id="L173" class="LineNr">173 </span>            <span class="Statement">if</span> (fragment.isBorderVertexWithIncomingEdge(v)) {
<span id="L174" class="LineNr">174 </span>                <span class="Type">auto</span> dest = fragment.getMsgThroughIncomingDest(v);
<span id="L175" class="LineNr">175 </span>                <span class="Statement">for</span> (<span class="Type">int</span> fid = <span class="Constant">0</span>; fid &lt; dest.size(); ++fid) {
<span id="L176" class="LineNr">176 </span>                    <span class="Statement">if</span> (dest.test(fid)) {
<span id="L177" class="LineNr">177 </span>                        messageBuffer.add_message(fid, v);
<span id="L178" class="LineNr">178 </span>                    }
<span id="L179" class="LineNr">179 </span>                }
<span id="L180" class="LineNr">180 </span>            }
<span id="L181" class="LineNr">181 </span>
<span id="L182" class="LineNr">182 </span>            <span class="Type">auto</span> tag = fragment.getVertexAttr(v);
<span id="L183" class="LineNr">183 </span>            <span class="Type">auto</span> u = tag2ID[tag];
<span id="L184" class="LineNr">184 </span>            deltaSet[u].insert(v);
<span id="L185" class="LineNr">185 </span>            <span class="Statement">for</span> (<span class="Type">auto</span> v1 : fragment.getParentsID(v)) {
<span id="L186" class="LineNr">186 </span>                <span class="Statement">if</span> (active[v1]) {
<span id="L187" class="LineNr">187 </span>                    --cnt[v1][tag];
<span id="L188" class="LineNr">188 </span>                    <span class="Statement">if</span> (cnt[v1][tag] == <span class="Constant">0</span>) {
<span id="L189" class="LineNr">189 </span>                        <span class="Type">auto</span> u1 = tag2ID[fragment.getVertexAttr(v1)];
<span id="L190" class="LineNr">190 </span>                        <span class="Statement">if</span> (prePattern[u].find(u1) != prePattern[u].end()) {
<span id="L191" class="LineNr">191 </span>                            active[v1] = <span class="Constant">false</span>;
<span id="L192" class="LineNr">192 </span>                            simQue.push(v1);
<span id="L193" class="LineNr">193 </span>                        }
<span id="L194" class="LineNr">194 </span>                    }
<span id="L195" class="LineNr">195 </span>                }
<span id="L196" class="LineNr">196 </span>            }
<span id="L197" class="LineNr">197 </span>        }
<span id="L198" class="LineNr">198 </span>
<span id="L199" class="LineNr">199 </span>        <span class="Statement">for</span> (<span class="Type">int</span> u = <span class="Constant">0</span>; u &lt; <span class="Statement">this</span>-&gt;query.getNumVertices(); ++u) {
<span id="L200" class="LineNr">200 </span>            partialResult[u] = diff(partialResult[u], deltaSet[u]);
<span id="L201" class="LineNr">201 </span>        }
<span id="L202" class="LineNr">202 </span>
<span id="L203" class="LineNr">203 </span>        temporal.cnt = cnt;
<span id="L204" class="LineNr">204 </span>        temporal.active = active;
<span id="L205" class="LineNr">205 </span>    }
<span id="L206" class="LineNr">206 </span>
<span id="L207" class="LineNr">207 </span>    <span class="Type">void</span> assemble(vector&lt;ResultT&gt; &amp;partialResults) {
<span id="L208" class="LineNr">208 </span>        unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt; finalResult;
<span id="L209" class="LineNr">209 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> resResult : partialResults) {
<span id="L210" class="LineNr">210 </span>            <span class="Statement">for</span> (<span class="Type">auto</span> simU : resResult) {
<span id="L211" class="LineNr">211 </span>                <span class="Type">auto</span> u = simU.first;
<span id="L212" class="LineNr">212 </span>                <span class="Statement">for</span> (<span class="Type">auto</span> v : simU.second) {
<span id="L213" class="LineNr">213 </span>                    finalResult[u].insert(v);
<span id="L214" class="LineNr">214 </span>                }
<span id="L215" class="LineNr">215 </span>            }
<span id="L216" class="LineNr">216 </span>        }
<span id="L217" class="LineNr">217 </span>        <span class="Type">int</span> tot = <span class="Constant">0</span>;
<span id="L218" class="LineNr">218 </span>
<span id="L219" class="LineNr">219 </span>        <span class="Statement">if</span> (<span class="Statement">this</span>-&gt;result_file != <span class="Constant">&quot;&quot;</span>) {
<span id="L220" class="LineNr">220 </span>            std::ofstream fout;
<span id="L221" class="LineNr">221 </span>            fout.open(<span class="Statement">this</span>-&gt;result_file);
<span id="L222" class="LineNr">222 </span>            <span class="Statement">for</span> (<span class="Type">auto</span> p : finalResult) {
<span id="L223" class="LineNr">223 </span>                <span class="Type">auto</span> u = p.first;
<span id="L224" class="LineNr">224 </span>                <span class="Statement">for</span> (<span class="Type">auto</span> v : p.second) {
<span id="L225" class="LineNr">225 </span>                    fout &lt;&lt; v &lt;&lt; <span class="Constant">&quot; -&gt; &quot;</span> &lt;&lt; u &lt;&lt; endl;
<span id="L226" class="LineNr">226 </span>                }
<span id="L227" class="LineNr">227 </span>                tot += p.second.size();
<span id="L228" class="LineNr">228 </span>            }
<span id="L229" class="LineNr">229 </span>            fout.close();
<span id="L230" class="LineNr">230 </span>        }
<span id="L231" class="LineNr">231 </span>
<span id="L232" class="LineNr">232 </span>        LOG(INFO) &lt;&lt; <span class="Constant">&quot;Total matches: &quot;</span> &lt;&lt; tot &lt;&lt; std::endl;
<span id="L233" class="LineNr">233 </span>    }
<span id="L234" class="LineNr">234 </span>
<span id="L235" class="LineNr">235 </span>    <span class="Type">template</span>&lt;<span class="Type">class</span> T&gt;
<span id="L236" class="LineNr">236 </span>    unordered_set&lt;T&gt; diff(<span class="Type">const</span> unordered_set&lt;T&gt; &amp;a, <span class="Type">const</span> unordered_set&lt;T&gt;&amp; b) {
<span id="L237" class="LineNr">237 </span>        unordered_set&lt;T&gt; ret;
<span id="L238" class="LineNr">238 </span>        <span class="Statement">for</span> (<span class="Type">auto</span> ele : a) {
<span id="L239" class="LineNr">239 </span>            <span class="Statement">if</span> (b.find(ele) == b.end()) {
<span id="L240" class="LineNr">240 </span>                ret.insert(ele);
<span id="L241" class="LineNr">241 </span>            }
<span id="L242" class="LineNr">242 </span>        }
<span id="L243" class="LineNr">243 </span>        <span class="Statement">return</span> ret;
<span id="L244" class="LineNr">244 </span>    }
<span id="L245" class="LineNr">245 </span>};
<span id="L246" class="LineNr">246 </span>
<span id="L247" class="LineNr">247 </span><span class="Type">int</span> main(<span class="Type">int</span> argc, <span class="Type">char</span> *argv[]) {
<span id="L248" class="LineNr">248 </span>
<span id="L249" class="LineNr">249 </span>    FLAGS_stderrthreshold = <span class="Constant">0</span>;
<span id="L250" class="LineNr">250 </span>
<span id="L251" class="LineNr">251 </span>    google::SetUsageMessage(<span class="Constant">&quot;Usage: mpiexec.hydra [mpi_opts] sim [grape_opts]&quot;</span>);
<span id="L252" class="LineNr">252 </span>    google::ParseCommandLineFlags(&amp;argc, &amp;argv, <span class="Constant">true</span>);
<span id="L253" class="LineNr">253 </span>    init_workers();
<span id="L254" class="LineNr">254 </span>
<span id="L255" class="LineNr">255 </span>    WorkerParams param;
<span id="L256" class="LineNr">256 </span>
<span id="L257" class="LineNr">257 </span>    param.algorithm = <span class="Constant">&quot;simulation&quot;</span>;
<span id="L258" class="LineNr">258 </span>    param.use_pattern = <span class="Constant">true</span>;
<span id="L259" class="LineNr">259 </span>    param.enable_assemble = <span class="Constant">true</span>;
<span id="L260" class="LineNr">260 </span>    param.graph_load_strategy = ONLY_IN;
<span id="L261" class="LineNr">261 </span>
<span id="L262" class="LineNr">262 </span>    google::ShutDownCommandLineFlags();
<span id="L263" class="LineNr">263 </span>
<span id="L264" class="LineNr">264 </span>    SimWorker&lt;<span class="Type">int</span>, <span class="Type">int</span>, VertexID, unordered_map&lt;VertexID, unordered_set&lt;VertexID&gt;&gt;, SimTemporal&gt; simWorker;
<span id="L265" class="LineNr">265 </span>    google::InitGoogleLogging(<span class="Constant">&quot;sim&quot;</span>);
<span id="L266" class="LineNr">266 </span>    simWorker.run(param);
<span id="L267" class="LineNr">267 </span>    google::ShutdownGoogleLogging();
<span id="L268" class="LineNr">268 </span>
<span id="L269" class="LineNr">269 </span>    worker_finalize();
<span id="L270" class="LineNr">270 </span>    <span class="Statement">return</span> <span class="Constant">0</span>;
<span id="L271" class="LineNr">271 </span>}
</pre>
</body>
</html>
<!-- vim: set foldmethod=manual : -->
